/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cz.muni.fi.veles.polyline;

import cz.muni.fi.veles.AbstractLocation;
import java.util.Collections;
import java.util.List;
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
import javax.faces.render.Renderer;

/**
 * RendererBase for polyline
 * @author Jan Ferko
 */
@ResourceDependencies({
    @ResourceDependency(name="polyline.js", target="head")
})
public class PolylineRendererBase extends Renderer{

    /**
     * 
     * @param component rendered component
     * @return key of used map server
     */
    public String getMapServer(UIComponent component){
        if(component == null || !(component instanceof AbstractPolyline)){
            return "";
        }
       AbstractPolyline polyline = (AbstractPolyline) component;
       return polyline.resolveMapServer().getId();
    }

    /**
     * Path of polyline
     * @param component rendered component
     * @return list of abstract location, which represent path of polyline
     */
    public List<AbstractLocation> getPath(UIComponent component){
        if(component == null || !(component instanceof AbstractPolyline)){
            return Collections.emptyList();
        }
        AbstractPolyline polyline = (AbstractPolyline) component;
        return polyline.getPath();
    }
}
